{extend name="$index_style_layout" /}

<!--SEO相关-->
{block name="head_title"}{$fid?($info['seo_title']?:$info['name']):$m_info['title']}{/block}
{block name="head_keword"}{$fid?($info['seo_keywords']?:$info['name']):$m_info['title']}{/block}
{block name="head_description"}{$info.seo_description}{/block}

{block name="body_content"}
<link rel="stylesheet" href="__STATIC__/index/default/list.css">
<script src='__STATIC__/js/iscroll.js'></script>
<div class="ListMainCont">

	<div class="SortBoxCont">
		<ul>
			<li class="{$type==0?'ck':''}"><a href="?type=0&mid={$mid}">播放记录</a></li>
			<li class="{$type==1?'ck':''}"><a href="?type=1&mid={$mid}">我的收藏</a></li>
		</ul>
	</div>
	<div class="ListArticles">

<!----------音乐播放器开始-------->
<br>
<link rel="stylesheet" href="__STATIC__/libs/jplayer/css/style.css"/>
<style type="text/css">
#voice{
    height:300px;
    width:100%;
    margin:0 auto;
}
.Lists .title a.choose{
	color:red;
}
 </style>
<div id="voice"></div>
<script src="__STATIC__/libs/jplayer/ttw-clarity-player.js?3"></script>
<script src="__STATIC__/libs/jplayer/yepnope.js"></script>
<script type="text/javascript">
var is_in_weixin = false;

var url_array = [

	{volist name="$listdb" id="rs"}
			{
                mp3:"{$rs['url']}",
                duration:"2:21",
                cover:"{$rs['info']['picurl']|default='/public/static/libs/jplayer/css/images/bg.jpg'}",
                title:"{$rs.title}",
                artist:"{$rs['info']['uid']|get_user_name}",
                background:'',
				play_time:{$rs.playtime},
				info_id:"{$rs.aid}",
				info_sid:"{$rs.sid}",
				info_page:"{:urls('content/show',['id'=>$rs['aid']])}?sid={$rs.sid}",
            },
	{/volist}
			 
        ];
var first_click = true;
var clarity;
$(function () {
		
        clarity = $('#voice').ttwClarityPlayer(url_array,{
				jPlayer:{
					supplied:'mp3',
					errorAlerts:true,	
					autoPlay:true,				
					warningAlerts:true,
					consoleAlerts:true,
					smoothPlayBar:true,
					ready: function (e) {
						var that = $(this);
						$(this).jPlayer("play",url_array[0].play_time);

						document.addEventListener("WeixinJSBridgeReady",function(){
							//clarity.play(url_array[0].play_time);
							that.jPlayer("play",url_array[0].play_time);
						});
					},
					play:function(){
						if(play_index==0 && first_click==true){
							first_click = false;
							$(this).jPlayer("play",url_array[0].play_time);
						}
						if(typeof(api_player_play)=='function'){
							api_player_play();
						}
					},
				}
			});

		
		//document.addEventListener("WeixinJSBridgeReady",function(){clarity.play(url_array[0].play_time);is_in_weixin=true;});
		//setTimeout(function(){if(is_in_weixin==false)clarity.play();}, 2000 );
        
		//$('#voice-size-picker').on('click', 'li', function(){
        //    $('#voice').attr('data-size', $(this).data('size'));
        //    clarity.manageLayout();
        //});
});

var play_index = 0;	//当前播放哪一首
function now_play_voice(index){	//当前正在播放第几首
	play_index = index;
	$(".Lists .title a").removeClass('choose');
	$(".Lists .title a").eq(index).addClass('choose');
	check_power(index);
}

</script>
<!--用到的JS-->
{include file="fav/inc"}
<!------------音乐播放器结束---------->

	{volist name="$listdb" id="rs"}
		<div class="Lists listdiv_{$key}">
			<div class="title"><a href="{:urls('content/show',['id'=>$rs['aid']])}?sid={$rs.sid}">{$rs.title|get_word=100}</a></div>
			<ul>
				<li>主题：《{$rs['info']['title']}》 <i onclick="del_fav({$rs.aid},{$rs.sid},{$key})" class="glyphicon glyphicon-remove-circle"></i></li>
			</ul>
		</div>
	{/volist}
	</div>
	 
</div>

<script>
function del_fav(id,sid,i){
	var url="{:urls('wxapp.fav/delete')}?type={$type}&id="+id+"&sid="+sid;
	$.get(url,function(res){
		if(res.code==0){
			layer.msg('成功移除');
			$(".listdiv_"+i).remove();
		}else{
			layer.alert(res.msg);
		}
	})
}
</script>

{/block}